package com.lifp.controller;

import com.lifp.dto.EmployeeQueryParam;
import com.lifp.entity.Employee;
import com.lifp.service.EmployeeService;
import com.lifp.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lifp
 * @date 2024/05/29
 */
@Api(tags = "员工管理")
@RestController
@RequestMapping("employee")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;

    @ApiOperation("添加员工")
    @PostMapping("add")
    public R<Employee> add(@RequestBody @Validated Employee employee){
        return R.ok(employeeService.add(employee));
    }

    @ApiOperation("列表查询")
    @GetMapping("list")
    public R<List<Employee>> list(EmployeeQueryParam queryParam){
        return R.ok(employeeService.listEmployee(queryParam));
    }
}
